﻿#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using BreakOutBattles.IO;
#endregion

namespace BreakOutBattles.Game
{
    /// <summary>
    /// A simple screen that notifies to the player that the game is currently waiting for
    /// a player to join the game.
    /// </summary>
    public class JoinWaitScreen
    {
        #region Fields
        private string waitMessage = "Waiting for player to connect...";
        private float rotationSpeed = MathHelper.Pi / 40;
        private float angle = 0;

        private IOManager ioManager;
        private SpriteFont font;
        private Texture2D loadIcon;
        private Vector2 waitMessagePos;
        private Vector2 position;
        private Vector2 origin;
        #endregion

        public JoinWaitScreen()
        {
            ioManager = IOManager.Instance;
            waitMessagePos = new Vector2(250, 250);
            position = new Vector2(600, 400);
        }

        public void LoadContent()
        {
            font = ioManager.LoadFont("matchReportDefaultFont");
            loadIcon = ioManager.LoadTexture(ContentFolders.MISC, "loader");
            origin = new Vector2(loadIcon.Width / 2, loadIcon.Height / 2);
        }

        public void Update(GameTime gameTime)
        {
            angle += rotationSpeed;
            angle = angle % (MathHelper.Pi * 2);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.DrawString(font, waitMessage, waitMessagePos, Color.Red);
            spriteBatch.Draw(loadIcon, position, null, Color.White, angle, origin, 1, SpriteEffects.None, 0);
        }
    }
}
